#!/usr/bin/python

import jsonss
from jsonss.service import JSONSSService
from jsonss.servercgi import JSONSSServerCGI

class MyService (JSONSSService):

    def __init__ (self):
        JSONSSService.__init__(self)
        self.add_method("MyMethod", "my-method", self.MyMethod)
        self.add_property("MyProperty", "my-property", self.getMyProperty)
        self.add_event("MyEvent")

    def MyMethod (self, p):
        self.fire_event("MyEvent", "my data")
        return str(p)

    def getMyProperty (self):
        return "my property"

server = JSONSSServerCGI()

server.add_service(MyService(), "MyService", "my-service")
res = server.process_request()
print "Content-type: text/plain; charset=utf-8\r\n\r\n", 
print res,

